﻿HmJS.$Import('ui.calendar.DatePicker');
//HmJS.$Import('core.domready');

HmJS.register('demo.module.ui.calendar.datepicker.minmaxdate', function ($ns) {
	var that = {};

	that.todo = function () {

		var Picker = $ns.ui.Picker;

		var myInput = $('myInput').set('value', new Date().format('%x')),
			myInput2 = $('myInput2').set('value', new Date().format('%x')),
			min = new Date().decrement('month', 2).decrement('day', 10),
			max = new Date().increment('month', 2).increment('day', 20);

		$('min').set('text', min.format('%x'));
		$('max').set('text', max.format('%x'));

		new Picker.Date(myInput, {
			minDate: min,
			maxDate: max
		});

		new Picker.Date(myInput2, {
			minDate: min.format('%x'),
			maxDate: max.format('%x')
		});

		new Picker.Date('myInput3', {
			pickerClass: 'datepicker_vista',
			format: '%Y-%m-%d',
			startView: 'days',
			yearPicker: false,
			minDate: '2011-1-19',
			maxDate: '2011-10-24',
			availableDates: {
				2011: {
					1: [19, 29, 31],
					3: [5, 19, 24],
					7: [6, 8, 20],
					8: [29],
					9: [15, 20],
					10: [2]
				}
			}
		});

		new Picker.Date('myInput4', {
			pickerClass: 'datepicker_vista',
			format: '%Y-%m-%d',
			startView: 'days',
			yearPicker: false,
			minDate: '2011-1-19',
			maxDate: '2011-10-24',
			availableDates: {
				2011: {
					1: [19, 29, 31],
					3: [5, 19, 24],
					7: [6, 8, 20],
					8: [29],
					9: [15, 20],
					10: [2]
				}
			},
			invertAvailable: true
		});

		new Picker.Date('myInput5', {
			yearPicker: false,
			draggable: false,
			format: '%e %b %Y',
			allowEmpty: false,
			maxDate: Date.parse(' 6 Dec 2010')
		});

	};

	return that;
});
